cmake_minimum_required(VERSION 2.8)

if(POLICY CMP0020)
    cmake_policy(SET CMP0020 NEW)
endif()

project(RabbitIm)

include(Files.cmake)

#资源
LIST(APPEND RABBITIM_RCC_FILES
    ${CMAKE_SOURCE_DIR}/Resource/Resource.qrc
    )

#翻译资源
GENERATED_QT_TRANSLATIONS(SOURCES ${RABBITIM_SOURCES} ${RABBITIM_UIS}
    OUT_QRC TRANSLATIONS_QRC_FILES)
string(TOLOWER ${CMAKE_BUILD_TYPE} BUILD_TYPE)
if(BUILD_TYPE STREQUAL "debug")
    LIST(APPEND RABBITIM_DEFINES DEBUG)
    LIST(APPEND RABBITIM_RCC_FILES
        ${TRANSLATIONS_QRC_FILES}
        )
endif()

LIST(APPEND RABBITIM_RCC_FILES
    Emoji/Emojis/emojione.qrc
    Emoji/Emojis/smileys.qrc
    )

#IF(ANDROID)
#    INSTALL(DIRECTORY Emoji/Emojis
#        DESTINATION assets
#        COMPONENT Runtime)
#ELSE()
#    INSTALL(DIRECTORY Emoji/Emojis
#        DESTINATION .
#        COMPONENT Runtime)
#ENDIF()

set(INCLUDE_DIRS
    ${RabbitCommon_DIR}/Src
    ${CMAKE_BINARY_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/common
    ${CMAKE_CURRENT_SOURCE_DIR}/Widgets/FrmCustom
    )
if(ANDROID)
    ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/android/QtAndroidUtils/android/QtAndroidUtilsModule/jni
        ${CMAKE_BINARY_DIR}/QtAndroidUtilsModule)
    LIST(APPEND RABBITIM_LIBS QtAndroidUtilsModule)
    LIST(APPEND INCLUDE_DIRS
        ${CMAKE_SOURCE_DIR}/android/QtAndroidUtils/android/QtAndroidUtilsModule/jni)
endif()

ADD_TARGET(NAME ${PROJECT_NAME}
    SOURCE_FILES ${RABBITIM_SOURCES} ${HEADER_FILES} ${RABBITIM_UIS} ${RABBITIM_RCC_FILES}
    LIBS RabbitCommon ${QT_LIBRARIES} ${RABBITIM_LIBS}
    DEFINITIONS RABBITCOMMON ${RABBITIM_DEFINES}
    PRIVATE_DEFINITIONS DLL_EXPORT
    INCLUDE_DIRS ${INCLUDE_DIRS}
    )

GENERATE_EXPORT_HEADER(${PROJECT_NAME})
string(TOLOWER ${PROJECT_NAME} LOWER_PROJECT_NAME)
set(INSTALL_HEADER_FILES ${INSTALL_HEADER_FILES}
    ${CMAKE_CURRENT_BINARY_DIR}/${LOWER_PROJECT_NAME}_export.h)
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/${LOWER_PROJECT_NAME}_export.h
    DESTINATION ${CMAKE_BINARY_DIR})

